package com.tang.entity;

import com.tang.config.EnumString;
import com.tang.config.ValidGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * @author tzf
 */
@Data
public class ValidVO {
    @Null(groups = ValidGroup.Crud.Create.class)
    @NotNull(groups = ValidGroup.Crud.Update.class, message = "应用ID不能为空")
    private String id;

    @Null(groups = ValidGroup.Crud.Create.class)
    @NotNull(groups = ValidGroup.Crud.Update.class, message = "appId不能为空")
    @Length(min = 6, max = 12, message = "appId长度必须位于6到12之间")
    private String appId;

    @NotBlank(groups = ValidGroup.Crud.Create.class, message = "名字为必填项")
    private String name;

    @Email(message = "请填入正确的邮箱地址")
    private String email;

    @EnumString(value = {"F", "M"}, message = "性别只允许F或M")
    private String sex;

    @NotEmpty(message = "级别不能为空")
    private String level;

    @DecimalMin(value = "12", message = "年龄不能小于12岁")
    @Range(min = 12, max = 70, message = "age must between 12 and 70")
    private Integer age;
}
